Imports System.Windows.Forms
Imports CommonNamespace

Public NotInheritable Class SubjectHeader
    Sub New(ByVal HeaderFilePath As String)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        Me.Location = Windows.Forms.Cursor.Position

        ' Add any initialization after the InitializeComponent() call.
        Me.ListView1.Columns(0).Width = CInt(ListView1.Width * 2 / 3)
        Me.ListView1.Columns(1).Width = CInt(ListView1.Width / 3)
        Select Case LCase(Trim(Mid(HeaderFilePath, Len(HeaderFilePath) - 2)))
            Case "hdr"
                'Dim AnalyzeFile As SingleOptimizedHdrImgLoader = New SingleOptimizedHdrImgLoader(HeaderFilePath)
                'Dim HeaderInformation As analyze_file = AnalyzeFile.HeaderInformation
                ''Dim nx_ny_nz As coordinate = New coordinate(HeaderInformation.imagedimensions.dimm(1), HeaderInformation.imagedimensions.dimm(2), HeaderInformation.imagedimensions.dimm(3))
                ''Dim dx_dy_dz As coordinate = New coordinate(LoadedRawData.nx_ny_nz.x * Convert.ToSingle(HeaderInformation.imagedimensions.pixdim(1)), LoadedRawData.nx_ny_nz.y * Convert.ToSingle(HeaderInformation.imagedimensions.pixdim(2)), LoadedRawData.nx_ny_nz.z * Convert.ToSingle(HeaderInformation.imagedimensions.pixdim(3)))

                'Dim item As ListViewItem
                'Dim str(2) As String
                'str(0) = "Length of Header"
                'str(1) = CStr(HeaderInformation.headerkey.sizeof_hdr)
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Database Name"
                'str(1) = HeaderInformation.headerkey.db_name
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Extents"
                'str(1) = HeaderInformation.headerkey.extents.ToString
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Session Error"
                'str(1) = CStr(HeaderInformation.headerkey.session_error)
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Regular"
                'str(1) = HeaderInformation.headerkey.regular
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "hkey_un0 value (r)"
                'str(1) = HeaderInformation.headerkey.hkey_un0
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Number of Dimensions"
                'str(1) = CStr(HeaderInformation.imagedimensions.dimm(0))
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "# of pixels in a row [NX]"
                'str(1) = CStr(HeaderInformation.imagedimensions.dimm(1))
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "# of pixel rows in slice [NY]"
                'str(1) = CStr(HeaderInformation.imagedimensions.dimm(2))
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "# of slices in volume [NZ]"
                'str(1) = CStr(HeaderInformation.imagedimensions.dimm(3))
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "# of volumes i.e. timepoints"
                'str(1) = CStr(HeaderInformation.imagedimensions.dimm(4))
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Spatial units of measure of voxel "
                'str(1) = HeaderInformation.imagedimensions.vox_offset.ToString
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Datatype of image"
                'str(1) = HeaderInformation.imagedimensions.datatype.ToString
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Bits per pixel"
                'str(1) = CStr(HeaderInformation.imagedimensions.bitpix)
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Voxel width in mm"
                'str(1) = HeaderInformation.imagedimensions.pixdim(1).ToString
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Voxel hieght in mm"
                'str(1) = HeaderInformation.imagedimensions.pixdim(2).ToString
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Slice thickness in mm"
                'str(1) = HeaderInformation.imagedimensions.pixdim(3).ToString
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Byte offset in img file"
                'str(1) = CStr(HeaderInformation.imagedimensions.vox_offset)
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Max calibration value"
                'str(1) = CStr(HeaderInformation.imagedimensions.cal_max)
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Min calibration value"
                'str(1) = CStr(HeaderInformation.imagedimensions.cal_min)
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Max pixel value"
                'str(1) = CStr(HeaderInformation.imagedimensions.glmax)
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Min pixel value"
                'str(1) = CStr(HeaderInformation.imagedimensions.glmin)
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
                'str(0) = "Slice orientation"
                'Select Case Val(HeaderInformation.datahistory.orient)
                '    Case 0
                '        str(1) = "Transverse unflipped"
                '    Case 1
                '        str(1) = "Coronal unflipped"
                '    Case 2
                '        str(1) = "Sagittal unflipped"
                '    Case 3
                '        str(1) = "Transverse flipped"
                '    Case 4
                '        str(1) = "Coronal flipped"
                '    Case 5
                '        str(1) = "Sagittal Flipped"
                'End Select
                'item = New ListViewItem(str)
                'ListView1.Items.Add(item)
            Case "par"
                Dim PhilipsFile As HeaderOnlyExtractor = New HeaderOnlyExtractor(HeaderFilePath)
                Dim HeaderInformation As ExtendedPARfileInfo = PhilipsFile.ExtendedPARHeader
                Dim item As ListViewItem
                Dim str(2) As String

                str(0) = "Patient(Name)"
                str(1) = HeaderInformation.patient_name
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Examination(Name)"
                str(1) = HeaderInformation.examination_name
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Protocol(Name)"
                str(1) = HeaderInformation.protocol_name
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Examination date/time"
                str(1) = HeaderInformation.exam_time_date
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Acquisition(nr)"
                str(1) = CStr(HeaderInformation.acquisition_nr)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Reconstruction(nr)"
                str(1) = CStr(HeaderInformation.reconstruction_nr)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Scan Duration [sec]"
                str(1) = CStr(HeaderInformation.scan_duration_secs)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Max. number of cardiac phases"
                str(1) = CStr(HeaderInformation.max_no_of_cardic_phases)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Max. number of echoes"
                str(1) = CStr(HeaderInformation.max_no_of_echoes)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Max. number of slices/locations"
                str(1) = CStr(HeaderInformation.max_no_of_slices)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Max. number of dynamics"
                str(1) = CStr(HeaderInformation.max_no_of_dynamics)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Max. number of mixes"
                str(1) = CStr(HeaderInformation.max_no_of_mixes)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Image pixel size [8 or 16 bits]"
                str(1) = CStr(HeaderInformation.image_pixel_size)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Technique()"
                str(1) = HeaderInformation.technique
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Scan(mode)"
                str(1) = HeaderInformation.scanmode
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Scan(resolution(x, y))"
                str(1) = HeaderInformation.scan_resolution_x_y(0) & "," & HeaderInformation.scan_resolution_x_y(1)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Scan(percentage)"
                str(1) = CStr(HeaderInformation.scan_percentage)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Recon(resolution(x, y))"
                str(1) = HeaderInformation.recon_resolution_x_y(0) & "," & HeaderInformation.recon_resolution_x_y(1)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Number of averages"
                str(1) = CStr(HeaderInformation.no_of_averages)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Repetition time [msec]"
                str(1) = CStr(HeaderInformation.repetition_time)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "FOV (ap,fh,rl) [mm]"
                str(1) = HeaderInformation.fov(0) & "," & HeaderInformation.fov(1) & "," & HeaderInformation.fov(2)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Slice thickness [mm]"
                str(1) = CStr(HeaderInformation.slice_thickness)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Slice gap [mm]"
                str(1) = CStr(HeaderInformation.slice_gap)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Water Fat shift [pixels]"
                str(1) = CStr(HeaderInformation.water_fat_shift)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Angulation midslice(ap,fh,rl)[degr]"
                str(1) = HeaderInformation.angulation_midslice(0) & "," & HeaderInformation.angulation_midslice(1) & "," & HeaderInformation.angulation_midslice(2)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Off Centre midslice(ap,fh,rl) [mm]"
                str(1) = HeaderInformation.off_center_midslice(0).ToString & "," & HeaderInformation.off_center_midslice(1).ToString & "," & HeaderInformation.off_center_midslice(2).ToString
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Flow compensation <0=no 1=yes>"
                str(1) = CStr(HeaderInformation.flow_compensation)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Presaturation     <0=no 1=yes>"
                str(1) = CStr(HeaderInformation.pre_saturation)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Cardiac(frequency)"
                str(1) = CStr(HeaderInformation.cardiac_frequency)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Min.RR(interval)"
                str(1) = CStr(HeaderInformation.min_rr_interval)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Max.RR(interval)"
                str(1) = CStr(HeaderInformation.max_rr_interval)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Phase encoding velocity [cm/sec]"
                str(1) = HeaderInformation.phase_encoding_velocity(0).ToString & "," & HeaderInformation.phase_encoding_velocity(1).ToString & "," & HeaderInformation.phase_encoding_velocity(2).ToString
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "MTC               <0=no 1=yes>"
                str(1) = CStr(HeaderInformation.mtc)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "SPIR              <0=no 1=yes>"
                str(1) = CStr(HeaderInformation.spir)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "EPI factor        <0,1=no EPI>"
                str(1) = CStr(HeaderInformation.epi_factor)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "TURBO factor      <0=no turbo>"
                str(1) = CStr(HeaderInformation.turbo_factor)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Dynamic scan      <0=no 1=yes> "
                str(1) = CStr(HeaderInformation.dynamic_scan)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Diffusion         <0=no 1=yes>"
                str(1) = CStr(HeaderInformation.diffusion)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Diffusion echo time [msec]"
                str(1) = CStr(HeaderInformation.diffusion_echo_time)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
                str(0) = "Inversion delay [msec]"
                str(1) = CStr(HeaderInformation.inversion_delay)
                item = New ListViewItem(str)
                ListView1.Items.Add(item)
        End Select
    End Sub

    Private Sub SubjectHeader_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
        Me.Close()
    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

    End Sub
End Class
